package reflectionAndAnnotation.reflection;

/**
 * @author zxl
 * @version 1.0
 * @date 2021/10/23 22:21
 */
public class Loader {
    public static void main(String[] args) throws ClassNotFoundException {

        //获得系统类加载器(AppClassLoader)
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获得扩展类加载器(ExtClassLoader)
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);

        //获得根加载器，由c/c++编写(bootstrapLoader)
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

        //测试当前类属于那个加载器
        Class<?> aClass = Class.forName("reflectionAndAnnotation.reflection.Loader");
        ClassLoader classLoader = aClass.getClassLoader();
        System.out.println(classLoader);

        //测试jdk内部类是谁加载
        Class<?> aClass1 = Class.forName("java.lang.Object");
        ClassLoader classLoader1 = aClass1.getClassLoader();
        System.out.println(classLoader1);

        //获得系统类加载器能加载的类
        String property = System.getProperty("java.class.path");
        System.out.println(property);
        /*
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\deploy.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\nashorn.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\javaws.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\plugin.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;
        C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;  核心
        D:\JSP\workspace\study\JavaFoundation\out\production\JavaFoundation;
        D:\JSP\idea\IntelliJ IDEA 2021.2.1\lib\idea_rt.jar
         */



    }
}
